package com.wangsh.splider.orders.pojo;

import java.util.Date;
import java.util.Map;
import java.util.TreeMap;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.wangsh.splider.common.pojo.BasePojo;
import com.wangsh.splider.system.pojo.ASysIp;
import com.wangsh.splider.system.pojo.ASysProxy;

/**
 * 订单请求历史表
 */
public class AOrdersUsers extends BasePojo<AOrdersUsers>
{
	private int id;
	private int clientId ;
	private int sysIpId ; 
	private int sysProxyId;
	private int usersId;
	private String email;
	private String phone;
	private String password ; 
	private String cookieTarget;
	private String cookieFini;
	private String httpSource;
	private String httpTarget;
	private String content;
	private int totalNum;
	private int succedNum;
	private int failedNum;
	private byte souType ; 
	private byte status;
	private Date createTime;
	private Date updateTime;
	private Date updateCookieTime ; 
	private Date pubTime ;
	
	/* 额外的字符串表示 */
	private String htmlContent ; 
	
	/*
	 * 枚举
	 */
	private String statusStr;
	private String souTypeStr ;
	/* 关联关系 */
	private AOrdersClient ordersClient ; 
	/* 关联关系 */
	private ASysIp sysIp;
	private ASysProxy sysProxy ; 
	
	/* --json信息-- */
	private JSONObject httpSourceJSON = new JSONObject(); 
	private JSONObject httpTargetJSON = new JSONObject(); 
	private JSONObject contentJSON = new JSONObject();

	private Map<String, String> enumsMap = new TreeMap<String, String>();

	public Map<String, String> getEnumsMap()
	{
		// 根据状态值获取字符串描述
		AOrdersUsersEnum[] enums = AOrdersUsersEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AOrdersUsersEnum enumTemp = enums[i];
			String key = enumTemp.toString();
			if (key.lastIndexOf("_") != -1)
			{
				key = key.substring(0, key.lastIndexOf("_"));
			}
			enumsMap.put(key + "-" + enumTemp.getStatus() + "", enumTemp.getName());
		}
		return enumsMap;
	}
	
	public String getStatusStr()
	{
		// 根据状态值获取字符串描述
		AOrdersUsersEnum[] enums = AOrdersUsersEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AOrdersUsersEnum enumTemp = enums[i];
			if (enumTemp.toString().startsWith("STATUS_"))
			{
				// 表示是状态的标识
				if (enumTemp.getStatus() == this.getStatus())
				{
					this.statusStr = enumTemp.getName();
					break;
				}
			}
		}
		return statusStr;
	}
	
	public String getSouTypeStr()
	{
		// 根据状态值获取字符串描述
		AOrdersUsersEnum[] enums = AOrdersUsersEnum.values();
		for (int i = 0; i < enums.length; i++)
		{
			AOrdersUsersEnum enumTemp = enums[i];
			if (enumTemp.toString().startsWith("SOUTYPE_"))
			{
				// 表示是状态的标识
				if (enumTemp.getStatus() == this.getSouType())
				{
					this.souTypeStr = enumTemp.getName();
					break;
				}
			}
		}
		return souTypeStr;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getUsersId()
	{
		return usersId;
	}

	public void setUsersId(int usersId)
	{
		this.usersId = usersId;
	}

	public String getEmail()
	{
		return email;
	}

	public void setEmail(String email)
	{
		this.email = email;
	}

	public String getPhone()
	{
		return phone;
	}

	public void setPhone(String phone)
	{
		this.phone = phone;
	}

	public String getContent()
	{
		return content;
	}

	public void setContent(String content)
	{
		this.content = content;
	}

	public int getTotalNum()
	{
		return totalNum;
	}

	public void setTotalNum(int totalNum)
	{
		this.totalNum = totalNum;
	}

	public int getSuccedNum()
	{
		return succedNum;
	}

	public void setSuccedNum(int succedNum)
	{
		this.succedNum = succedNum;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public Date getPubTime()
	{
		return pubTime;
	}

	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}

	public void setEnumsMap(Map<String, String> enumsMap)
	{
		this.enumsMap = enumsMap;
	}

	public String getCookieTarget()
	{
		return cookieTarget;
	}

	public void setCookieTarget(String cookieTarget)
	{
		this.cookieTarget = cookieTarget;
	}

	public String getCookieFini()
	{
		return cookieFini;
	}

	public void setCookieFini(String cookieFini)
	{
		this.cookieFini = cookieFini;
	}

	public String getHttpSource()
	{
		return httpSource;
	}

	public void setHttpSource(String httpSource)
	{
		this.httpSource = httpSource;
	}

	public String getHttpTarget()
	{
		return httpTarget;
	}

	public void setHttpTarget(String httpTarget)
	{
		this.httpTarget = httpTarget;
	}

	public JSONObject getHttpSourceJSON()
	{
		try
		{
			JSONObject resultJSON = (JSONObject) JSON.parse(this.httpSource);
			if(resultJSON == null)
			{
				return this.httpSourceJSON ; 
			}
			return resultJSON ; 
		} catch (Exception e)
		{
		}
		return httpSourceJSON;
	}

	public JSONObject getHttpTargetJSON()
	{
		try
		{
			JSONObject resultJSON =  (JSONObject) JSON.parse(this.httpTarget);
			if(resultJSON == null)
			{
				return this.httpTargetJSON ; 
			}
			return resultJSON ; 
		} catch (Exception e)
		{
		}
		return httpTargetJSON;
	}
	
	public JSONObject getContentJSON()
	{
		try
		{
			JSONObject resultJSON = (JSONObject) JSON.parse(this.content);
			if(resultJSON == null)
			{
				return this.contentJSON ; 
			}
			return resultJSON ; 
		} catch (Exception e)
		{
		}
		return contentJSON;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password)
	{
		this.password = password;
	}

	public String getHtmlContent()
	{
		return htmlContent;
	}

	public void setHtmlContent(String htmlContent)
	{
		this.htmlContent = htmlContent;
	}

	public int getClientId()
	{
		return clientId;
	}

	public void setClientId(int clientId)
	{
		this.clientId = clientId;
	}

	public int getFailedNum()
	{
		return failedNum;
	}

	public void setFailedNum(int failedNum)
	{
		this.failedNum = failedNum;
	}

	public AOrdersClient getOrdersClient()
	{
		return ordersClient;
	}

	public void setOrdersClient(AOrdersClient ordersClient)
	{
		this.ordersClient = ordersClient;
	}

	public ASysIp getSysIp()
	{
		return sysIp;
	}

	public void setSysIp(ASysIp sysIp)
	{
		this.sysIp = sysIp;
	}

	public ASysProxy getSysProxy()
	{
		return sysProxy;
	}

	public void setSysProxy(ASysProxy sysProxy)
	{
		this.sysProxy = sysProxy;
	}

	public int getSysProxyId()
	{
		return sysProxyId;
	}

	public void setSysProxyId(int sysProxyId)
	{
		this.sysProxyId = sysProxyId;
	}

	public int getSysIpId()
	{
		return sysIpId;
	}

	public void setSysIpId(int sysIpId)
	{
		this.sysIpId = sysIpId;
	}

	public byte getSouType()
	{
		return souType;
	}

	public void setSouType(byte souType)
	{
		this.souType = souType;
	}

	public Date getUpdateCookieTime()
	{
		return updateCookieTime;
	}

	public void setUpdateCookieTime(Date updateCookieTime)
	{
		this.updateCookieTime = updateCookieTime;
	}
}
